﻿// -------------------------------------------------------------------------
//    @FileName         :    NFLogicServerPlayerPlugin.cpp
//    @Author           :    gaoyi
//    @Date             :   2023-07-10
//    @Email			:    445267987@qq.com
//    @Module           :    NFLogicServerPlayerPlugin
//
// -------------------------------------------------------------------------

#include "NFComm/NFPluginModule/NFIPluginManager.h"
#include "NFComm/NFPluginModule/NFConfigDefine.h"
#include "NFComm/NFPluginModule/NFIConfigModule.h"

#include "NFMMOLogicPlayerPlugin.h"

#include <NF1v1Part.h>
#include <NFActivityEightPart.h>
#include <NFAheadCostPart.h>
#include <NFArenaPart.h>
#include <NFAuctionCompetitionPart.h>
#include <NFAutoRecoverPart.h>
#include <NFAvatarPart.h>
#include <NFBattleDrugPart.h>
#include <NFBattlePart.h>
#include <NFCDPart.h>
#include <NFCePart.h>
#include <NFChallengeTowerPart.h>
#include <NFChatPart.h>
#include <NFCheatPart.h>
#include <NFCityBuffPart.h>
#include <NFCounterPart.h>
#include <NFCreditPart.h>
#include <NFCreditShopPart.h>
#include <NFDungeonPart.h>
#include <NFEscortPart.h>
#include <NFEventLogPart.h>
#include <NFFashionPart.h>
#include <NFFriendModule.h>
#include <NFGiftPart.h>
#include <NFRegisterCache.h>
#include <NFWhiteListCache.h>
#include <NFGlobalMiscData.h>
#include <NFGMPart.h>
#include <NFGuildCompetitionPart.h>
#include <NFHallPart.h>
#include <NFHealthGamePart.h>
#include <NFHeroPart.h>
#include <NFInfiniteDungeonPart.h>
#include <NFLegentRoadPart.h>
#include <NFLevelBlessPart.h>
#include <NFLevelPart.h>
#include <NFLicensePart.h>
#include <NFLifeSkillPart.h>
#include <NFLoginNoticeData.h>
#include <NFMapPart.h>
#include <NFMasterQuestPart.h>
#include <NFMilitantPart.h>
#include <NFMultiLevelPart.h>
#include <NFNianPracticePart.h>
#include <NFNoviceGuidePart.h>
#include <NFOnlineModule.h>
#include <NFOnlineRewardPart.h>

#include <NFPackagePart.h>
#include <NFPartnerPart.h>
#include <NFPayPart.h>
#include <NFPhantomTroupePart.h>
#include <NFPlatPart.h>

#include "NFSkillPart.h"
#include "NFBuffPart.h"
#include "NFMiscPart.h"

#include "NFLogicConfig.h"

#include <NFPvePart.h>
#include <NFQuestModule.h>
#include <NFQuestPart.h>
#include <NFRaidPart.h>
#include <NFRetrivePart.h>
#include <NFReturnPart.h>
#include <NFRisingPurchasePart.h>
#include <NFRoulettePart.h>
#include <NFServerLevelMgr.h>
#include <NFShopPart.h>
#include <NFSignInMonthPart.h>
#include <NFSignPart.h>
#include <NFSixExperimentPart.h>
#include <NFSkinPart.h>
#include <NFSkyArenaPart.h>
#include <NFSnsModule.h>
#include <NFSnsPart.h>
#include <NFStatePart.h>
#include <NFTitlePart.h>
#include <NFTormentTowerPart.h>
#include <NFTradePart.h>
#include <NFTransGetRole.h>
#include <NFTrapTowerPart.h>
#include <NFTreasureHuntPart.h>
#include <NFWantedPart.h>
#include <NFWelfarePart.h>

#include "NFActivityEightModule.h"
#include "NFActivityModule.h"
#include "NFBattleCorpsModule.h"
#include "NFGMModule.h"
#include "NFLogicPlayerModule.h"
#include "NFSessionModule.h"
#include "NFLoginModule.h"

#include "NFPlayerMgr.h"
#include "NFPlayer.h"
#include "NFPartModule.h"
#include "NFSession.h"

#include "NFTransGetRoleList.h"
#include "NFLogicObService.h"
#include "NFMallModule.h"
#include "NFMapModule.h"
#include "NFMasterModule.h"
#include "NFMirrorModule.h"
#include "NFMirrorSessionMgr.h"
#include "NFMultiLevelModule.h"
#include "NFPackageModule.h"
#include "NFRoomModule.h"
#include "NFServiceModule.h"
#include "NFSkyArenaModule.h"
#include "NFTransCreateRole.h"
#include "NFTransGetAcc.h"
#include "NFTransInsertRole.h"
#include "NFTransLoadRole.h"
#include "NFTransMapMsg.h"
#include "NFTransOpStoreageBag.h"
#include "NFTransPlayerBase.h"
#include "NFTransSaveRole.h"
#include "NFWelfareMgr.h"
#include "NFWelfareModule.h"
#include "NFLogicCommon/NFWelfareConf.h"

#ifdef NF_DYNAMIC_PLUGIN

NF_EXPORT void DllStartPlugin(NFIPluginManager* pm)
{
    CREATE_PLUGIN(pm, NFMMOLogicPlayerPlugin)
    
};

NF_EXPORT void DllStopPlugin(NFIPluginManager* pm)
{
    DESTROY_PLUGIN(pm, NFMMOLogicPlayerPlugin)
};

#endif


//////////////////////////////////////////////////////////////////////////

int NFMMOLogicPlayerPlugin::GetPluginVersion()
{
    return 0;
}

std::string NFMMOLogicPlayerPlugin::GetPluginName()
{
    return GET_CLASS_NAME(NFMMOLogicPlayerPlugin);
}

void NFMMOLogicPlayerPlugin::Install()
{
    REGISTER_MODULE_TICK(m_pObjPluginManager, NFCLogicPlayerModule, NFCLogicPlayerModule);
    REGISTER_MODULE(m_pObjPluginManager, NFPartModule, NFPartModule);
    REGISTER_MODULE(m_pObjPluginManager, NFLogicObServiceModule, NFLogicObServiceModule);
    REGISTER_MODULE(m_pObjPluginManager, NFSessionModule, NFSessionModule);
    REGISTER_MODULE(m_pObjPluginManager, NFLoginModule, NFLoginModule);
    REGISTER_MODULE(m_pObjPluginManager, NFSnsModule, NFSnsModule);
    REGISTER_MODULE(m_pObjPluginManager, NFFriendModule, NFFriendModule);
    REGISTER_MODULE(m_pObjPluginManager, NFOnlineModule, NFOnlineModule);
    REGISTER_MODULE(m_pObjPluginManager, NFWelfareModule, NFWelfareModule);
    REGISTER_MODULE(m_pObjPluginManager, NFMirrorModule, NFMirrorModule);
    REGISTER_MODULE(m_pObjPluginManager, NFServiceModule, NFServiceModule);
    REGISTER_MODULE(m_pObjPluginManager, NFRoomModule, NFRoomModule);
    REGISTER_MODULE(m_pObjPluginManager, NFMultiLevelModule, NFMultiLevelModule);
    REGISTER_MODULE(m_pObjPluginManager, NFBattleCorpsModule, NFBattleCorpsModule);
    REGISTER_MODULE(m_pObjPluginManager, NFActivityEightModule, NFActivityEightModule);
    REGISTER_MODULE(m_pObjPluginManager, NFSkyArenaModule, NFSkyArenaModule);
    REGISTER_MODULE(m_pObjPluginManager, NFMasterModule, NFMasterModule);
    REGISTER_MODULE(m_pObjPluginManager, NFActivityModule, NFActivityModule);
    REGISTER_MODULE(m_pObjPluginManager, NFMallModule, NFMallModule);
    REGISTER_MODULE(m_pObjPluginManager, NFMapModule, NFMapModule);
    REGISTER_MODULE(m_pObjPluginManager, NFGMModule, NFGMModule);
    REGISTER_MODULE(m_pObjPluginManager, NFQuestModule, NFQuestModule);
    REGISTER_MODULE(m_pObjPluginManager, NFPackageModule, NFPackageModule);
}

void NFMMOLogicPlayerPlugin::Uninstall()
{
    UNREGISTER_MODULE(m_pObjPluginManager, NFCLogicPlayerModule, NFCLogicPlayerModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFPartModule, NFPartModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFLogicObServiceModule, NFLogicObServiceModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFSessionModule, NFSessionModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFLoginModule, NFLoginModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFSnsModule, NFSnsModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFFriendModule, NFFriendModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFOnlineModule, NFOnlineModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFWelfareModule, NFWelfareModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFMirrorModule, NFMirrorModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFServiceModule, NFServiceModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFRoomModule, NFRoomModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFMultiLevelModule, NFMultiLevelModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFBattleCorpsModule, NFBattleCorpsModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFActivityEightModule, NFActivityEightModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFSkyArenaModule, NFSkyArenaModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFMasterModule, NFMasterModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFActivityModule, NFActivityModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFMallModule, NFMallModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFMapModule, NFMapModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFGMModule, NFGMModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFQuestModule, NFQuestModule);
    UNREGISTER_MODULE(m_pObjPluginManager, NFPackageModule, NFPackageModule);
}

bool NFMMOLogicPlayerPlugin::InitShmObjectRegister()
{
    NFServerConfig* pConfig = FindModule<NFIConfigModule>()->GetAppConfig(NF_ST_LOGIC_SERVER);
    NF_ASSERT(pConfig);

    uint32_t maxOnlinePlayerNum = pConfig->GetMaxOnlinePlayerNum() * 1.2;

    /////////////////////mgr//////////////////////
    REGISTER_SINGLETON_SHM_OBJ(NFLogicConfig);
    REGISTER_SINGLETON_SHM_OBJ(NFWhiteListCache);
    REGISTER_SINGLETON_SHM_OBJ(NFGlobalMiscData);
    REGISTER_SINGLETON_SHM_OBJ(NFLoginNoticeData);
    REGISTER_SINGLETON_SHM_OBJ(NFServerLevelMgr);
    REGISTER_SINGLETON_SHM_OBJ(NFWelfareMgr);
    REGISTER_SINGLETON_SHM_OBJ(NFMirrorSessionMgr);

    /////////////////////player//////////////////////////
    REGISTER_SHM_OBJ(NFSession, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ_WITH_HASH(NFPlayer, maxOnlinePlayerNum);

    REGISTER_SINGLETON_SHM_OBJ(NFPlayerMgr);
    REGISTER_SHM_OBJ(NFPart, 0);

    ////////////////////////////part////////////////////////////
    REGISTER_SHM_OBJ(NFPackagePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFSkillPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFGMPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFBuffPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFMiscPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFHeroPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFPvePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFBattleDrugPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFCreditPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFPartnerPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFMapPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFLifeSkillPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFEscortPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFShopPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFTrapTowerPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFSixExperimentPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFWelfarePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFMilitantPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFTitlePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFFashionPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFSnsPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFGuildCompetitionPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFMasterQuestPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFAuctionCompetitionPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFLicensePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFSkyArenaPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFCreditShopPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFPhantomTroupePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFStatePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFArenaPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFSignPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFSignInMonthPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFDungeonPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFCheatPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFTreasureHuntPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFWantedPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFPayPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFMultiLevelPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFActivityEightPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFGiftPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFCePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFChatPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFAutoRecoverPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFRisingPurchasePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFLevelBlessPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFTormentTowerPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFLegentRoadPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NF1v1Part, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFChallengeTowerPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFInfiniteDungeonPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFRaidPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFRetrivePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFReturnPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFPlatPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFTradePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFLevelPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFAvatarPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFAheadCostPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFBattlePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFCDPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFCityBuffPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFCounterPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFEventLogPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFHealthGamePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFNianPracticePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFNoviceGuidePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFOnlineRewardPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFRoulettePart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFSkinPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFHallPart, maxOnlinePlayerNum);
    REGISTER_SHM_OBJ(NFQuestPart, maxOnlinePlayerNum);

    ////////////////////////////trans////////////////////////////
    REGISTER_SHM_OBJ(NFTransPlayerBase, 0);
    REGISTER_SHM_OBJ(NFTransAccBase, 0);
    REGISTER_SHM_OBJ(NFTransGetAcc, maxOnlinePlayerNum/10);
    REGISTER_SHM_OBJ(NFTransGetRoleList, maxOnlinePlayerNum/10);
    REGISTER_SHM_OBJ(NFTransCreateRole, maxOnlinePlayerNum/10);
    REGISTER_SHM_OBJ(NFTransInsertRole, maxOnlinePlayerNum/10);
    REGISTER_SHM_OBJ(NFTransLoadRole, maxOnlinePlayerNum/10);
    REGISTER_SHM_OBJ(NFTransSaveRole, maxOnlinePlayerNum/10);
    REGISTER_SHM_OBJ(NFTransGetRole, maxOnlinePlayerNum/10);
    REGISTER_SHM_OBJ(NFTransMapMsg, maxOnlinePlayerNum/10);
    REGISTER_SHM_OBJ(NFTransOpStoreageBag, maxOnlinePlayerNum/10);

    ////////////////////////////db////////////////////////////
    REGISTER_SINGLETON_SHM_OBJ(NFRegisterCache);

    return true;
}